Module modules.gui

File name: qui.py Author: Martin Jůda Python Version: 3.7 Description: Module with main GUI container

Expand source code
"""
    File name: qui.py
    Author: Martin Jůda
    Python Version: 3.7
    Description: Module with main GUI container
"""
import tkinter as tk

from modules.constants import DISPLAY_DIMENSIONS
from modules.frames import ReadCardPage


class GUI(tk.Tk):
    """Main GUI window"""
    def __init__(self, *args, **kwargs):
        super(GUI, self).__init__(*args, **kwargs)

        self.title("Přístupový systém")
        self.geometry(DISPLAY_DIMENSIONS)
        self.grid_rowconfigure(0, weight=1)
        self.grid_columnconfigure(0, weight=1)
        self._frame = None
        self.switch_frame_by_class(ReadCardPage)

    def switch_frame_by_class(self, frame_class, *args, **kwargs):
        """Switch GUI frame by class name, instantiate frame and start post init actions

        Args:
            frame_class (class): Frame class
            *args: arguments
            **kwargs: key arguments

        """
        new_frame = frame_class(self, *args, **kwargs)
        if self._frame is not None:
            self._frame.destroy()
            del self._frame
        self._frame = new_frame
        self._frame.grid(column=0, row=0, sticky="nsew")
        self._frame.post_init_actions()

    def switch_frame_by_instance(self, frame):
        """Switch GUI frame by instance and start post init actions

        Args:
            frame: Frame object

        """
        if self._frame is not None:
            self._frame.destroy()
        self._frame = frame
        self._frame.grid(column=0, row=0, sticky="nsew")
        self._frame.post_init_actions()

Classes

class GUI (*args, **kwargs)

Main GUI window

Return a new Toplevel widget on screen SCREENNAME. A new Tcl interpreter will be created. BASENAME will be used for the identification of the profile file (see readprofile). It is constructed from sys.argv[0] without extensions if None is given. CLASSNAME is the name of the widget class.

Expand source code
class GUI(tk.Tk):
    """Main GUI window"""
    def __init__(self, *args, **kwargs):
        super(GUI, self).__init__(*args, **kwargs)

        self.title("Přístupový systém")
        self.geometry(DISPLAY_DIMENSIONS)
        self.grid_rowconfigure(0, weight=1)
        self.grid_columnconfigure(0, weight=1)
        self._frame = None
        self.switch_frame_by_class(ReadCardPage)

    def switch_frame_by_class(self, frame_class, *args, **kwargs):
        """Switch GUI frame by class name, instantiate frame and start post init actions

        Args:
            frame_class (class): Frame class
            *args: arguments
            **kwargs: key arguments

        """
        new_frame = frame_class(self, *args, **kwargs)
        if self._frame is not None:
            self._frame.destroy()
            del self._frame
        self._frame = new_frame
        self._frame.grid(column=0, row=0, sticky="nsew")
        self._frame.post_init_actions()

    def switch_frame_by_instance(self, frame):
        """Switch GUI frame by instance and start post init actions

        Args:
            frame: Frame object

        """
        if self._frame is not None:
            self._frame.destroy()
        self._frame = frame
        self._frame.grid(column=0, row=0, sticky="nsew")
        self._frame.post_init_actions()

Ancestors

  • tkinter.Tk
  • tkinter.Misc
  • tkinter.Wm

Methods

def switch_frame_by_class(self, frame_class, *args, **kwargs)

Switch GUI frame by class name, instantiate frame and start post init actions

Args

frame_class : class
Frame class
*args
arguments
**kwargs
key arguments
Expand source code
def switch_frame_by_class(self, frame_class, *args, **kwargs):
    """Switch GUI frame by class name, instantiate frame and start post init actions

    Args:
        frame_class (class): Frame class
        *args: arguments
        **kwargs: key arguments

    """
    new_frame = frame_class(self, *args, **kwargs)
    if self._frame is not None:
        self._frame.destroy()
        del self._frame
    self._frame = new_frame
    self._frame.grid(column=0, row=0, sticky="nsew")
    self._frame.post_init_actions()
def switch_frame_by_instance(self, frame)

Switch GUI frame by instance and start post init actions

Args

frame
Frame object
Expand source code
def switch_frame_by_instance(self, frame):
    """Switch GUI frame by instance and start post init actions

    Args:
        frame: Frame object

    """
    if self._frame is not None:
        self._frame.destroy()
    self._frame = frame
    self._frame.grid(column=0, row=0, sticky="nsew")
    self._frame.post_init_actions()